//
//  BaseTabbarView.swift
//  SwiftUI_App
//
//  Created by qingzhou on 2021/6/25.
//

import SwiftUI

struct BaseTabbarView: View {
    
    var body: some View {
        TabBarView()
    }
}

struct TabBarView: View {
    
    @State private var selectedTab: Int = 0
    
    var body: some View {
        TabView(selection: $selectedTab) {
            HomeViw(title: "首页")
                .tabItem {
                Text(String.Common.home)
                Image( selectedTab == 0 ?  String.Image.icon_home_selected
                        : String.Image.icon_home)
                    .resizable()
                    .scaledToFit()
                    .frame(width:23,height: 23)
            }
            .onTapGesture {
                selectedTab = 0
            }
            .tag(0)
            
            
            SecondTabView()
                .tabItem {
                    Text(String.Common.dynamic)
                    Image(selectedTab == 1 ? String.Image.icon_dynamic_selected :
                        String.Image.icon_dynamic)
                        .resizable()
                        .frame(width:23,height: 23)
                }
                .onTapGesture {
                    selectedTab = 1
                }
                .tag(1)
        }
        .accentColor(Color(#colorLiteral(red: 0.843783319, green: 0.1125835255, blue: 0.6564487219, alpha: 1)))
    }
}


struct BaseTabbarView_Previews: PreviewProvider {
    static var previews: some View {
        BaseTabbarView()
    }
}
